﻿using System;

namespace jsonar
{
	internal sealed class Decimal : Json
	{
		public decimal Val() { return this.val; }
		private decimal val = 0m;

		public Decimal(decimal num) { this.val = num; }

		public override int getValue(int dft) { try { return (int)this.val; } catch { return dft; } }
		public override uint getValue(uint dft) { try { return (uint)this.val; } catch { return dft; } }
		public override long getValue(long dft) { try { return (long)this.val; } catch { return dft; } }
		public override float getValue(float dft) { try { return (float)this.val; } catch { return dft; } }
		public override double getValue(double dft) { try { return (double)this.val; } catch { return dft; } }
		public override decimal getValue(decimal dft) { return this.val; }
		public override bool getValue(bool dft) { if (this.val == 1m) return true; if (this.val == 0m) return false; return dft; }
		public override string getValue(string dft) { return this.val.ToString(); }

		public override string ToString() { return this.val.ToString(); }
	}
}
